import { TodoType } from "../reducers/todos"

type TodoAction =
  {
    type: 'UPDATE_STATE' // 字面量类型
    payload: number
  }
  | {
    type: 'DEL_TODO'
    payload: number
  }
  | {
    type: 'add_TODO'
    payload: TodoType
  }



export const updateState = (id: number): TodoAction => {
  return {
    type: 'UPDATE_STATE',
    payload: id
  }
}

export const delState = (id: number): TodoAction => {
  return {
    type: 'DEL_TODO',
    payload: id
  }
}

export const addTodos = (name: string): TodoAction => {
  // console.log(data, 333);

  return {
    type: 'add_TODO',
    payload: {
      id: Date.now(),
      name,
      isDone: false

    }

  }
}